/**
 * Created by zhujiaming on 2017/5/15.
 */
import React, {Component} from 'react';
import {
    StyleSheet,
    ActivityIndicator
}from 'react-native';
import {connect} from 'react-redux';

class LoadingDialog extends Component {
    constructor() {
        super();
    }

    render() {
        if (!this.props.showLoading) {
            return null;
        }
        return (<ActivityIndicator
            animating={true}
            style={styles.centering}
            size="large"/>)
    }
}

const styles = StyleSheet.create({
    centering: {
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: 'rgba(0, 0, 0, 0.3)',
    }
});
export default connect((state) => {
        const {showLoading} = state.component;
        return {
            showLoading
        }
    }
)(LoadingDialog);